﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>paser arguments</title>
<meta name="GENERATOR" content="WinCHM">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>

<body>
<P><FONT face=Arial size=2>
<TABLE style="BORDER-COLLAPSE: collapse" borderColor=#000000 cellSpacing=0 
cellPadding=2 width="100%" border=1>
  
  <TR>
    <TD>&nbsp;java (SDK)</TD>
    <TD>&nbsp;c&nbsp;(NDK)</TD>
    <TD>&nbsp;</TD></TR>
  <TR>
    <TD>&nbsp;String</TD>
    <TD><SPAN 
      style="DISPLAY: inline! important; FLOAT: none; WORD-SPACING: 0px; FONT: 12px arial; TEXT-TRANSFORM: none; COLOR: rgb(39,61,73); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(237,237,237); orphans: 2; widows: 2; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px">char 
      *</SPAN></TD>
    <TD>&nbsp;<A 
      href="http://www.velocityreviews.com/forums/t135697-jni-jint-int.html">http://www.velocityreviews.com/forums/t135697-jni-jint-int.html</A></TD></TR>
  <TR>
    <TD>&nbsp;char</TD>
    <TD>&nbsp;<SPAN 
      style="DISPLAY: inline! important; FLOAT: none; WORD-SPACING: 0px; FONT: 12px arial; TEXT-TRANSFORM: none; COLOR: rgb(39,61,73); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BACKGROUND-COLOR: rgb(237,237,237); orphans: 2; widows: 2; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px">jchar<SPAN 
      class=Apple-converted-space>&nbsp;</SPAN></SPAN></TD>
    <TD>&nbsp;&nbsp;<A 
      href="http://www.velocityreviews.com/forums/t135697-jni-jint-int.html">http://www.velocityreviews.com/forums/t135697-jni-jint-int.html</A></TD></TR>
  <TR>
    <TD>&nbsp;</TD>
    <TD>&nbsp;</TD>
    <TD>&nbsp;</TD></TR>
  <TR>
    <TD>&nbsp;jint</TD>
    <TD>&nbsp;int</TD>
    <TD>&nbsp;<A 
      href="http://www.coderanch.com/t/274304/java/java/Converting-int-when-calls-jint">http://www.coderanch.com/t/274304/java/java/Converting-int-when-calls-jint</A></TD></TR></TABLE> </FONT></P>
<FONT size=2><FONT face=Courier><STRONG><FONT 
style="BACKGROUND-COLOR: #ffff00">Demo :</FONT> </STRONG> <U><STRONG><FONT 
color=#0000ff>D:\PhucAndroid\NDKDemos\AndroidNativeDemo\AndroidNativeDemo</FONT></STRONG></U></FONT></FONT>
<br>
<p>#include "com_marakana_NativeLib.h"<br>
  #include &lt;stdio.h&gt;</p>
<p><FONT style="BACKGROUND-COLOR: #ffff00">JNIEXPORT jstring JNICALL 
Java_com_marakana_<STRONG>YourClassName</STRONG> 
  _hello(JNIEnv * env, jobject obj) 
{</FONT>        <br>
  return (*env)-&gt;NewStringUTF(env, "Hello World!");<br>
  }</p>
<p>&nbsp;</p>
<p><FONT face=Courier color=#ff0000 size=5><STRONG>chuyền 
vào 2 số nguyên và trả về tổng của nó&nbsp;:</STRONG></FONT> <BR><FONT style="BACKGROUND-COLOR: #ffff00">JNIEXPORT jint JNICALL 
Java_com_marakana_<STRONG>YourClassName</STRONG>  
 _add(JNIEnv * env, jobject obj, jint value1, 
jint value2) {</FONT>            <br>
  return (value1 + value2);<br>
  }<BR>           
</p>
<p><STRONG><FONT face=Courier color=#ff0000 size=5>trả về 
một&nbsp;chuỗi&nbsp;đọc từ một file txt&nbsp;:</FONT></STRONG>
  <br><FONT 
style="BACKGROUND-COLOR: #ffff00">JNIEXPORT jstring JNICALL 
Java_com_marakana_<STRONG>YourClassName</STRONG>   
_getStringFromFile(JNIEnv * env, jobject obj) 
{</FONT>
          <br>
  FILE* fp;<br>
  char line[20];<br>
  fp =
    fopen("/sdcard/demo.txt","r");<br>
  while(fgets(line,20,fp)!=NULL) {<br>
  break;<br>
  }<br>
  fclose(fp);<br>
  return (*env)-&gt;NewStringUTF(env,line);<br>
  }<br>           
</p>
</body>
</html>
